package com.iot.manage.service;

import com.alibaba.fastjson.JSONObject;
import com.iot.manage.dao.AppMapper;
import com.iot.manage.pojo.App;
import com.iot.manage.pojo.Area;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class AppService {

    @Autowired
    private AppMapper appMapper;

    public List<App> findAppsInfo(String query, int pagenum, int pagesize) {
        return appMapper.findAppsInfo(query,pagesize * (pagenum - 1),pagesize * pagenum);
    }

    public int countAppsInfo(String query) {
        return appMapper.countAppsInfo(query);
    }

    public void deleteAppById(String appId) {
        appMapper.deleteAreaById(appId);
    }

    public void addApp(JSONObject params) {
        appMapper.addApp(params);
    }

    public App findAppByIdOrCode(String params) {
        return appMapper.findAppByIdOrCode(params);
    }

    public void updateAppInfo(JSONObject params) {
        appMapper.updateAppInfo(params);
    }

    public List<Area> findAllAllotArea() {
        return appMapper.findAllAllotArea();
    }

    public List<String> findAllotAreaById(String appId) {
        return appMapper.findAllotAreaById(appId);
    }

    public void deleteAreasOfAllotById(String appId) {
        appMapper.deleteAreasOfAllotById(appId);
    }

    public void addAreasOfAllotById(List<Map<String, String>> list) {
        appMapper.addAreasOfAllotById(list);
    }

    public void deleteRelevancyUserById(String appId) {
        appMapper.deleteRelevancyUserById(appId);
    }

    public void deleteRelevancyAreaById(String appId) {
        appMapper.deleteRelevancyAreaById(appId);
    }
}
